<template>
    <div>
        <top-simple-search @searchFun="getList" @addFun="showDialog"></top-simple-search>
        <simple-table ref="myTable" api-url="addressBook/useful">
            <el-table-column align="left" prop="title" label="名称">
            </el-table-column>
            <el-table-column align="left" prop="dept_name" label="部门" show-tooltip-when-overflow>
            </el-table-column>
            <el-table-column align="left" prop="phone" label="电话"/>
            <el-table-column align="center" prop="no_order" label="排序" v-if="hasPermissions('moveup')||hasPermissions('movedown')">
                <template slot-scope="{row}">
                    <my-button icon="el-icon-top" @click="moveUp(row.id)" handle="moveup"></my-button>
                    <my-button icon="el-icon-bottom" @click="moveDown(row.id)" handle="movedown"></my-button>
                </template>
            </el-table-column>
            <el-table-column label="操作" v-if="hasPermissions('editphone')||hasPermissions('Delete')">
                <template slot-scope="{row}">
                    <my-button @click="toEdit(row)" handle="editphone">编辑</my-button>
                    <delete-button @click="toDelete(row.id)"></delete-button>
                </template>
            </el-table-column>
        </simple-table>
        <detail-dialog :visible.sync="visible" v-if="visible" @reloadList="getList" :row="currRow" :disabled="disabled"></detail-dialog>
    </div>
</template>
<script>
    import simpleTable from "@/mixins/SimpleTable";
    import DetailDialog from "./DetailDialog";
    import useful from "@/api/addressBook/useful/index";
    export default {
        name: "Useful",
        components: {DetailDialog},
        mixins: [simpleTable],
        data() {
            return {
                apiUrl:"useful",
                visible: false
            }
        },
        methods: {
            showDialog() {
                this.visible = true
            },
            moveUp(id){
                useful.moveUp(id).then(res=>{
                    this.getList()
                    this.msgSuccess(res.msg);
                })
            },
            moveDown(id){
                useful.moveDown(id).then(res=>{
                    this.getList()
                    this.msgSuccess(res.msg);
                })
            },
        }
    }
</script>
